Compilers are used to translate computer source code from a higher level computing language into a lower level computing language such as machine code for executing on computer hardware. This enables a programmer to create source code in a high level language without particular consideration of the computer hardware to be used. The compiler carries out various tasks including verifying syntax and semantics of the source code, type checking, code optimization, and generation of target code to be executed on computer hardware.
A compiler often has a built in type system comprising a plurality of rules for associating a property (referred to as a type) with each computed value. These types are used by the compiler for type checking which identifies type errors in the source code and generates alerts so that bugs can be identified semantic errors and memory errors prevented. A type checker checks if operations expecting a certain type are being used with types for which that operation is not logical. Type systems may also be used for optimizations carried out by the compiler, to facilitate documentation and for multiple dispatch.
The embodiments described below are not limited to implementations which solve any or all of the disadvantages of known compilers.